<%@	taglib uri="http://java.sun.com/jstl/core_rt" prefix="c-rt"%>
<%@	taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ tag pageEncoding="UTF-8"%>
<%@ attribute name="prodInvMap" required="true" type="java.util.Map"%>
<%@ attribute name="prodMajors" required="true" type="java.util.List"%>
//加购商品
$(":select[id*=selectMs_]").change(function(){
	var aopId = $(this).attr('id').split('_')[1];
	var msId = $(this).val();
	selectMainSpec(aopId,msId);
});

function selectMainSpec(prodId, msId){
	<c-rt:forEach items="${prodMajors}" var="prodMajor" varStatus="status">
		if ( "${prodMajor.mainSpecId}" == msId ){
			$("#changeCampaignImg").attr("src","${imgDomain}${fn:split(prodMajor.imgMain,',')[0]}");
		}
	</c-rt:forEach>
	var secSpec = $("#selectMs_"+prodId).data(msId);
	var secSpecHtml = '';
	if(secSpec == null || $(secSpec).length>1){
		secSpecHtml = '<option value="">请选择</option>';
	}
	if(secSpec != null){
		$(secSpec).each(function(index, temp) {
			if(parseInt($(document.body).data('inv_'+temp.specId),10)>0){
				secSpecHtml += "<option value=\""+temp.specId+"\">"+temp.specName+"</option>";
			}else{
				secSpecHtml += "<option value=\""+temp.specId+"\" disabled=\"disabled\">"+temp.specName+"-售完</option>";
			}
		});
	}
	$(":select[id*=selectMs_"+prodId+"] option:[value="+msId+"]").attr("selected","true");
	$(":select[id*=selectSs_"+prodId+"]").html(secSpecHtml);
	$(":select[id*=selectSs_]").change(function(){
		var ssId = $(this).val();
		$(":select[id*=selectSs_"+prodId+"] option:[value="+ssId+"]").attr("selected","true");
	});
}
<c-rt:forEach items="${prodInvMap}" var="entry">
	$(document.body).data('inv_${entry.key}','${entry.value.availableInventory + entry.value.cancelInventory - entry.value.soldInventory}');
</c-rt:forEach>
var aopSecSpec;
var aopHaseQty;
	<c-rt:forEach items="${prodMajors}" var="prodMajor" varStatus="status">
			$("#selectMs_${prodMajor.productId}").data('${prodMajor.mainSpecId}',${prodMajor.jsonDetail});
			aopSecSpec = ${prodMajor.jsonDetail};
			aopHaseQty = false;
			$(aopSecSpec).each(function(index, temp) {
				if(parseInt($(document.body).data('inv_'+temp.specId),10)>0){aopHaseQty = true;}
			});
			if(!aopHaseQty){
				$(":option[value=${prodMajor.mainSpecId}]").attr('disabled','disabled').append('-售完');
			}
	</c-rt:forEach>
	<c-rt:if test="${fn:length(prodMajors) == 1}">
		$("#selectMs_${prodMajors[0].productId}").change();
	</c-rt:if>
